using System.Data.Entity.ModelConfiguration;

namespace OBUCare.Core.Models.Mapping
{
    public class DICT_TYPE_VALUEMap : EntityTypeConfiguration<DICT_TYPE_VALUE>
    {
        public DICT_TYPE_VALUEMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.DICT_TITLE)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.DICT_CODE)
                .HasMaxLength(50);

            this.Property(t => t.REMARK)
                .HasMaxLength(500);

            this.Property(t => t.CREATED_BY)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(6);

            this.Property(t => t.MODIFY_BY)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("DICT_TYPE_VALUE");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.DICT_TYPE_ID).HasColumnName("DICT_TYPE_ID");
            this.Property(t => t.DICT_TITLE).HasColumnName("DICT_TITLE");
            this.Property(t => t.DICT_INDEX).HasColumnName("DICT_INDEX");
            this.Property(t => t.DICT_CODE).HasColumnName("DICT_CODE");
            this.Property(t => t.REMARK).HasColumnName("REMARK");
            this.Property(t => t.STATUS).HasColumnName("STATUS");
            this.Property(t => t.CREATED_BY).HasColumnName("CREATED_BY");
            this.Property(t => t.CREATED_DATE).HasColumnName("CREATED_DATE");
            this.Property(t => t.MODIFY_BY).HasColumnName("MODIFY_BY");
            this.Property(t => t.MODIFY_DATE).HasColumnName("MODIFY_DATE");

            // Relationships
            this.HasRequired(t => t.DICT_TYPE)
                .WithMany(t => t.DICT_TYPE_VALUE)
                .HasForeignKey(d => d.DICT_TYPE_ID)
                .WillCascadeOnDelete(true); //开启级联删除

        }
    }
}
